package com.power.sifa.correction.dao;

import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.Repository;
import org.springframework.data.repository.query.Param;
import com.power.sifa.correction.model.Crc_camera;

import javax.transaction.Transactional;
import java.io.Serializable;
import java.util.List;

/**
 * 摄像头信息 持久层(hibernate)
 */

public interface Crc_cameraDao extends JpaRepository<Crc_camera, Serializable>, JpaSpecificationExecutor<Crc_camera>, Repository<Crc_camera, Serializable>, Crc_cameraDaoCustom<Crc_camera, Serializable> {

   @Modifying
   @Transactional
   @Query("update Crc_camera s set s.deleted = 1  where  s.id in (:ids) ")
   void removeByIds(@Param("ids") List<String> ids);

   @Query("select latlng from Crc_camera ")
   List<String> findAllLatlng();

   @Query(value = "SELECT id, name, lat, lng, deleted, latlng FROM crc_camera WHERE id LIKE 'tw%'", nativeQuery = true)
   List<Crc_camera> findCrcCameraList();
}
